package NetWork;

import java.io.IOException;
import java.net.*;
import java.util.*;

public class UDPDicServer extends MyUDPServer{
    //创建hashmap储存字典
    private Map<String,String> dict = new HashMap<>();
    //创造构建方法给父类构造
    public UDPDicServer(int port) throws SocketException {
        super(port);

        dict.put("dog","小狗");
        dict.put("cat","小猫");
        dict.put("fuck","窝草");
    }
    //重写process方法
    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"未找到该单词");
    }

    public static void main(String[] args) throws IOException {
        UDPDicServer udpDicServer = new UDPDicServer(6666);
        udpDicServer.start();
    }

}
